package com.xinlianshiye.im.response

import com.fasterxml.jackson.annotation.JsonFormat
import com.xinlianshiye.im.bean.Record
import java.util.*

/**
 * @Author zw
 * @Description  聊天记录
 * @Date 15:55 2019/9/4
 * @Param
 */
class RecordView {
    // 表ID
    var id: Int? = null
    // 聊天内容
    var content: String? = null
    // 聊天发送时间
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    var beforedate: Date? = null
    // 聊天发送时间
    @JsonFormat(pattern = " HH:mm:ss", timezone = "GMT+8")
    var afterdate: Date? = null
    // 消息类型 文字图片 语言
    var type: Int? = null
    var fromId: Int? = null
    var toId: Int? = null
    //是否已经读取过，true代表读取过，false代表未读
    var state: Boolean? = null
    // 判断是否是接受者 还是发送者 true 代表发送者 false代表接受者
    var issend: Boolean? = null
    // 标记是否删除  一旦删除在消息列表中 则查不出该条记录
    var signdel: Boolean? = null

    companion object {
        @JvmStatic
        fun init(record: Record): RecordView {
            val view = RecordView()
            view.id = record.id
            view.beforedate = Date.from(record.createTime)
            view.afterdate = Date.from(record.createTime)
            view.issend = record.isSender
            view.type = record.type
            view.state = record.haveRead
            view.content = record.content
            view.fromId = record.ownerId
            view.toId = record.otherId
            return view
        }
    }
}